package com.yanq.liancar.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.yanq.liancar.R;
import com.yanq.liancar.bean.FullServiceBean;

import java.util.List;

public class SeeServiceImgAdapter extends BaseAdapter {
    private Context context;
    private List<FullServiceBean.DataBean.FilesBean> datas;
    private LayoutInflater layoutInflater;

    public SeeServiceImgAdapter(Context context, List<FullServiceBean.DataBean.FilesBean> list) {

        this.context = context;

        this.datas = list;

        layoutInflater = LayoutInflater.from(context);

    }

    @Override
    public int getCount() {

        return datas.size();

    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = layoutInflater.inflate(R.layout.item_service_img, parent, false);
            holder.imageView = convertView.findViewById(R.id.addimg);
            holder.delImg=convertView.findViewById(R.id.img_del);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.delImg.setVisibility(View.GONE);
        Glide.with(context).load(datas.get(position).getWebPath()).into(holder.imageView);


        return convertView;
    }

    static class ViewHolder {
        ImageView imageView;
        ImageView delImg;
    }
}
